<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('热采集数据列表')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">

<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="locationId" name="locationId" th:value="${location.locationId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>热表ID：</label>
                                <input type="text" id="meterId" name="meterId" th:value="${meterId}"/>
                            </li>
                            <li class="select-time">
                                <label>采集时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" id="check" onclick="check()" shiro:hasPermission="data:meter:check">
                    <i class="fa fa-plus"></i> 数据采集
                </a>
                <a class="btn btn-success" id="detail" onclick="detail()" >
                    <i class="fa fa-plus"></i> 图表分析
                </a>
            </div>
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table" data-auto-refresh="true" data-auto-refresh-interval="60" data-show-print="true"></table>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: bootstrap-table-export-js" />
<th:block th:include="include :: bootstrap-table-auto-refresh-js" />
<th:block th:include="include :: bootstrap-table-print-js" />
<script th:inline="javascript">
    var prefix = ctx + "data/meter";
    $(function() {
        var options = {
            url: prefix + "/list",
            modalName: "热表数据",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            showExport: true,
            sortName: "createTime",
            sortOrder: "desc",
            columns: [ {
                field: 'id',
                title: '主键id',
                visible: false
            },
                {
                    field: 'location.locationName',
                    title: '地址全称',
                    sortable: true
                },
                {
                    field: 'meterId',
                    title: '热表ID',
                    formatter: function(value, row, index) {
                        return '<a href="javascript:void(0)" onclick="detail(\'' + row.meterId + '\')">' + value + '</a>';
                    }
                },
                {
                    field: 'heat',
                    title: '热量'
                },
                {
                    field: 'flow',
                    title: '流量'
                },
                {
                    field: 'power',
                    title: '功率'
                },
                {
                    field: 'instant',
                    title: '瞬时流量'
                },
                {
                    field: 'inlet',
                    title: '进水温度'
                },
                {
                    field: 'outlet',
                    title: '出水温度'
                },
                {
                    field: 'workTime',
                    title: '工作时间'
                },
                {
                    field: 'gatherTime',
                    title: '热表时间'
                },
                {
                    field: 'createTime',
                    title: '采集时间'
                }]
        };
        $.table.init(options);
    });




    $('#btnExpand').click(function() {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    $('#btnCollapse').click(function() {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });

    $('#btnRefresh').click(function() {
        queryLocationTree();
    });
    /* 数据展示 */
    function detail() {
        var meterId = $("#meterId").val();
        var url = ctx + 'report/meter/' + meterId;
        $.modal.parentTab("热表数据展示", url);
    }
    /**
     * 热表数据采集
     */
    function check(){
        var meterId = $("#meterId").val();
        $.operate.post(prefix + "/check", { "meterId": meterId });
    }

</script>
</body>
</html>